jQuery.noConflict();
jQuery(function($) {
	$("#show-driver-login-form").click(function() {
		$("#driver-join-login-div").stop(true).toggle(
			function() {
				$(".scan-2D-code > img").css({
					"width": "120%"
				});
			},
			function() {
				$(".scan-2D-code > img").css({
					"width": "160%"
				});
			}
		);
		
	});
	
	// 以下是轮播图动画函数区域，translateCarouselAnimation
	let carouselUL1 = $("#carousel-ul1").children();
	let carouselCircleUL = $(".carousel-circle-ul");
	carouselUL1.each(function(i, ele) {
		carouselCircleUL.append($(`<li>${(i+1)}</li>`));

	});
	transformCarousel($("#show-drivers"), carouselUL1, carouselCircleUL);
	// 下面这个函数因为使用到了jQuery语法,选择器,所以要放在jQuery加载环境中,不能写在jQuery.ready()之外
	function transformCarousel(obj1Father, obj1, obj2, startIndex = 0, event1 = "mouseover", event2 = "mouseleave") {
		try {
			if(obj1 && obj2) {
				// 如果这两个对象存在，则进行下一步的轮播图操作
				obj1.set01 = null;
				obj1.zeroIndex01 = startIndex;
				obj1.flag01 = true;
				obj1.len = obj1.length; // 最先开始进行轮播图的第一个元素的下标，0为从第一个元素开始
				clearInterval(obj1.set01); // 节流阀作用
				obj2.children().on("mouseover", function() {
					obj1.flag01 = false;
					obj1.zeroIndex01 = $(this).index();
					carousel01(obj1, obj2, obj1.zeroIndex01);
					console.log(obj1.zeroIndex01);
				});
				obj1.set01 = setInterval(function() {
					if(obj1.flag01) {
						carousel01(obj1, obj2, obj1.zeroIndex01);
						obj1.zeroIndex01++;
						if(obj1.zeroIndex01 === obj1.len) {
							obj1.zeroIndex01 = 0;
						}
						return;
					}
					console.dir("gogogo123  " + obj1.flag01);

				}, 3000);
				// 当鼠标悬浮于某个元素之上时，一般为父元素上，则暂时停止轮播图
				obj1Father.on(event1 + " click mouseenter", function(e) {
					obj1.flag01 = false;
					console.log(e.type);
					return;
				});
				obj1Father.on(event2 + " mouseout", function(e) {
					obj1.flag01 = true;
					console.log(e.type);
					return;
				});

				return;
			}
			throw new Error("这个对象不存在，请保证获取的是正确的对象。");
		} catch(err) {
			alert(err.message);
		}
	}
	// 轮播图的又一个封装函数
	function carousel01(obj1, obj2, zeroIndex01) {
		obj1.eq(zeroIndex01)
		.css({
			"transform": "translate(0, 0)",
			"opacity": "1"
		})
		.siblings()
		.css({
			"transform": "",
			"opacity": "0"
		});
		obj2.children().eq(zeroIndex01)
		.css({
			"background-color": "#ffffcc",
			"color": "#0494fd",
			"border": "2px solid #d37468"
		})
		.siblings()
		.css({
			"background-color": "",
			"color": "",
			"border": ""
		});
	}
});